#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <malloc.h>

int* twoSum(int* nums, int numsSize, int target, int* returnSize) {
    int i = 0;
    int j = 0;
    int *ok = NULL;
    ok = (int*)malloc(sizeof(int) * 2);
    for (i = 0; i < numsSize - 1; i++)
    {
        for (j = i + 1; j < numsSize; j++)
        {
            if ((nums[i] <= target / 2) && (nums[j] >= target / 2) && ((nums[i] + nums[j]) == target))
            {
                ok[0] = i;
                ok[1] = j;
                return ok;
            }
            else if ((nums[i] >= target / 2) && (nums[j] <= target / 2) && ((nums[i] + nums[j]) == target))
            {
                ok[0] = i;
                ok[1] = j;
                return ok;
            }
        }
    }
    return ok;
}

int main()
{
    int nums[4] = { 11,7,11,2 };
    int target = 9;
    int numsSize = 4;
    int returnSize = 2;
    printf("%d", twoSum(nums, numsSize, target, returnSize)[0]);
    printf("%d", twoSum(nums, numsSize, target, returnSize)[1]);
}